package com.oedtech.esl.model.esl;

import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import java.io.Serializable;
import java.util.Date;
import java.util.List;

/**
 * 电子标签类
 */
@Entity(name="esl_tab")
public class EslTab implements Serializable,Cloneable{
    @Id @Column(name="tiny_ip")
    private String tinyIP;                            //标签IP
    @Column(name="network_ip")
    private String networkIP;                     //基站IP

    private String lcdType;                          //屏幕尺寸

    private String str0;                            //保留
    private int downloadTimes;                      //下载次数
    @DateTimeFormat(pattern = "yyyy-MM-dd　HH:mm:ss")
    private Date downloadDateTime;                  //发生下载时间的日期时间
    private String versionStr;                          //标签版本号

    private String storeCode;                    //门店编码
    private String sid;                          //异步回调报文中回传该session id
    private String backUrl;                      //价签更新的结果通过调用此url异步返回
    private String name;                         //用于指定screen的名字
    private Integer defaultPageId;               //设定价签显示的页号。取值从0开始，最大值取决于ESL所支持的最大页数量。
    private Integer gidIndex;
    private Integer pushTimes;
    private Integer firmwareId;                 //固件ID
    private Date feedbackTime;

    @OneToOne
    @JoinColumn(name = "firmwareId",referencedColumnName="id",insertable=false,updatable=false)
    @NotFound(action= NotFoundAction.IGNORE)
    private EslFirmware eslFirmware;
    @OneToMany
    @JoinColumn(name = "tiny_ip",referencedColumnName="tiny_ip",insertable=false,updatable=false)
    @NotFound(action= NotFoundAction.IGNORE)
    private List<EslImg> eslImgList;                              //绑定的商品


    @OneToOne
    @JoinColumn(name = "tiny_ip",referencedColumnName="tiny_ip",insertable=false,updatable=false)
    @NotFound(action= NotFoundAction.IGNORE)
    private EslStatus eslStatus;


    public String getTinyIP() {
        return tinyIP;
    }

    public void setTinyIP(String tinyIP) {
        this.tinyIP = tinyIP;
    }

    public String getNetworkIP() {
        return networkIP;
    }

    public void setNetworkIP(String networkIP) {
        this.networkIP = networkIP;
    }

    public String getLcdType() {
        return lcdType;
    }

    public void setLcdType(String lcdType) {
        this.lcdType = lcdType;
    }

    public String getStr0() {
        return str0;
    }

    public void setStr0(String str0) {
        this.str0 = str0;
    }

    public int getDownloadTimes() {
        return downloadTimes;
    }

    public void setDownloadTimes(int downloadTimes) {
        this.downloadTimes = downloadTimes;
    }

    public Date getDownloadDateTime() {
        return downloadDateTime;
    }

    public void setDownloadDateTime(Date downloadDateTime) {
        this.downloadDateTime = downloadDateTime;
    }


    public String getVersionStr() {
        return versionStr;
    }

    public void setVersionStr(String versionStr) {
        this.versionStr = versionStr;
    }

    public String getStoreCode() {
        return storeCode;
    }

    public void setStoreCode(String storeCode) {
        this.storeCode = storeCode;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getBackUrl() {
        return backUrl;
    }

    public void setBackUrl(String backUrl) {
        this.backUrl = backUrl;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Integer getDefaultPageId() {
        return defaultPageId;
    }

    public void setDefaultPageId(Integer defaultPageId) {
        this.defaultPageId = defaultPageId;
    }

    public Integer getGidIndex() {
        return gidIndex;
    }

    public void setGidIndex(Integer gidIndex) {
        this.gidIndex = gidIndex;
    }

    public Integer getPushTimes() {
        return pushTimes;
    }

    public void setPushTimes(Integer pushTimes) {
        this.pushTimes = pushTimes;
    }

    public EslFirmware getEslFirmware() {
        return eslFirmware;
    }

    public void setEslFirmware(EslFirmware eslFirmware) {
        this.eslFirmware = eslFirmware;
    }

    public List<EslImg> getEslImgList() {
        return eslImgList;
    }

    public void setEslImgList(List<EslImg> eslImgList) {
        this.eslImgList = eslImgList;
    }

    public Integer getFirmwareId() {
        return firmwareId;
    }

    public void setFirmwareId(Integer firmwareId) {
        this.firmwareId = firmwareId;
    }

    public Date getFeedbackTime() {
        return feedbackTime;
    }

    public void setFeedbackTime(Date feedbackTime) {
        this.feedbackTime = feedbackTime;
    }

    public EslStatus getEslStatus() {
        return eslStatus;
    }

    public void setEslStatus(EslStatus eslStatus) {
        this.eslStatus = eslStatus;
    }

    @Override
    public String toString() {
        return "EslTab{" +
                "tinyIP='" + tinyIP + '\'' +
                ", networkIP='" + networkIP + '\'' +
                ", lcdType='" + lcdType + '\'' +
                ", str0='" + str0 + '\'' +
                ", downloadTimes=" + downloadTimes +
                ", downloadDateTime=" + downloadDateTime +
                ", versionStr='" + versionStr + '\'' +
                ", storeCode='" + storeCode + '\'' +
                ", sid='" + sid + '\'' +
                ", backUrl='" + backUrl + '\'' +
                ", name='" + name + '\'' +
                ", defaultPageId=" + defaultPageId +
                ", gidIndex=" + gidIndex +
                ", pushTimes=" + pushTimes +
                ", firmwareId=" + firmwareId +
                ", feedbackTime=" + feedbackTime +
                '}';
    }

    @Override
    public EslTab clone() {
        EslTab eslTab = null;
        try{
            eslTab = (EslTab)super.clone();
        }catch(CloneNotSupportedException e) {
            e.printStackTrace();
        }
        return eslTab;
    }
}
